//
//  HeaderView.m
//  iOS实战
//
//  Created by clz on 2019/10/26.
//  Copyright © 2019 clz. All rights reserved.
//

#import "HeaderView.h"
#import "Commont.h"
#import <Masonry.h>

@interface HeaderView()


@end

@implementation HeaderView

- (instancetype)init
{
    self = [super init];
    if (self) {
        
        self.backgroundColor = [UIColor whiteColor];
        
        UIView *view = [[UIView alloc]init];
        view.backgroundColor = RGBHex(0x21B6B4);
        view.layer.cornerRadius = 2;
        view.clipsToBounds = YES;
        [self addSubview:view];
        [view mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(20);
            make.size.mas_equalTo(CGSizeMake(4, 16));
            make.top.equalTo(self).offset(20);
            make.bottom.equalTo(self);
        }];
        
        self.titleLabel = [[UILabel alloc]init];
        self.titleLabel.font = [UIFont boldSystemFontOfSize:18];
        self.titleLabel.textColor = RGBHex(0x263238);
        [self addSubview:self.titleLabel];
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(view.mas_right).offset(8);
            make.centerY.equalTo(view);
        }];
        
        UIButton *moreButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [moreButton setTitle:@"更多" forState:UIControlStateNormal];
        [moreButton setImage:[UIImage imageNamed:@"home_Enter"] forState:UIControlStateNormal];
        [moreButton setTitleColor:RGBHex(0x90A4AE) forState:UIControlStateNormal];
        moreButton.titleLabel.font = [UIFont systemFontOfSize:13];
        moreButton.imageEdgeInsets = UIEdgeInsetsMake(0,50, 0, 0);
        moreButton.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, -5);
        [moreButton addTarget:self action:@selector(moreAction:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:moreButton];
        [moreButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self).offset(-20);
            make.centerY.equalTo(view);
            make.size.mas_equalTo(CGSizeMake(55, 15));
        }];
    }
    return self;
}

- (void)moreAction:(UIButton *)sender{
    if (self.moreBlock) {
        self.moreBlock();
    }
}



@end
